//
//  SingleListTableViewCell.m
//  Shengzhuli
//
//  Created by 卡忙科技 on 16/8/15.
//  Copyright © 2016年 kamangkeji. All rights reserved.
//

#import "SingleListTableViewCell.h"
#import <UIButton+WebCache.h>

@interface SingleListTableViewCell()

@property (weak, nonatomic) IBOutlet UILabel *shopNameLab;
@property (weak, nonatomic) IBOutlet UILabel *singleStatusLab;
@property (weak, nonatomic) IBOutlet UIButton *iconBtn;
@property (weak, nonatomic) IBOutlet UILabel *titleLab;
@property (weak, nonatomic) IBOutlet UILabel *allMoneyLab;
@property (weak, nonatomic) IBOutlet UIButton *payBtn;

@end

@implementation SingleListTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    self.payBtn.layer.borderColor = [UIColor redColor].CGColor;
}

- (void)setModel:(SingleListModel *)model
{
    _model = model;
    self.shopNameLab.text = model.shopName;
    self.allMoneyLab.text = [NSString stringWithFormat:@"实付金额：¥%.2f元",model.totalPrice];
    if (model.status == SingleTypeStatusUnpay) {
        self.singleStatusLab.text = @"待付款";
        self.allMoneyLab.text = [NSString stringWithFormat:@"应付总额：¥%.2f元",model.totalPrice];
    }else if (model.status == SingleTypeStatusAlreadyPay){
        self.singleStatusLab.text = @"待收货";
        if (self.isSeller) {
            self.singleStatusLab.text = @"待发货";
        }
    }else if (model.status == SingleTypeStatusAlreadySend){
        self.singleStatusLab.text = @"待收货";
        if (self.isSeller) {
            self.singleStatusLab.text = @"已发货";
        }
    }else if (model.status == SingleTypeStatusCompleted){
        self.singleStatusLab.text = @"已完成";
    }else if (model.status == SingleTypeStatusAlreadyEvaluate){
        self.singleStatusLab.text = @"已评价";
    }
    [self.iconBtn sd_setBackgroundImageWithURL:[NSURL URLWithString:model.thumbnailUrl] forState:UIControlStateNormal placeholderImage:GetImage(@"default_goods_image")];
    self.titleLab.text = model.productName;
}
- (IBAction)btnClick:(id)sender
{
    if (self.detailBlock) {
        self.detailBlock(self.model);
    }
}
- (IBAction)payClick:(UIButton *)sender
{
    if (self.payBlock) {
        self.payBlock(self.model);
    }
}

@end
